<div class="row">
    <div class="col-md-12">
        <div class="portlet">
            <div class="portlet-title">
                <div class="caption">
                    <i class="fa fa-sitemap"></i>
                    <strong><?=__('Departments Listing')?></strong>
                </div>
                <div class="actions">
                    <a data-toggle="modal" href="<?=url('department/modal')?>" data-target="#ajax-modal" class="btn default yellow-stripe">
                        <i class="fa fa-plus"></i>
                        <?=__('Add Department')?>
                    </a>
                </div>
            </div>
            <div class="portlet-body">
                <? if (count($departments) == 0): ?>
                <div class="note note-danger">
                    <h4 class="block"><?=__('Sorry !')?></h4>
                    <p>
                        <?=__('No records found!')?>
                    </p>
                </div>
                <? else: ?>
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                        <tr class="heading">
                            <th><?=__('Department')?></th>
                            <th><?=__('Staff')?></th>
                            <th width="60"><?=__('Sort')?></th>
                            <th width="200"><?=__('Actions')?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <? foreach ($departments as $dept): ?>
                            <? $userNums = OaDepartments::countUsers($dept['dept_id']); ?>
                            <tr>
                                <td>
                                    <?=str_repeat('&nbsp; ', $dept['level']*4)?>
                                    <i class="fa <?=on($dept['is_parent'], 'fa-plus icon-danger', 'fa-minus icon-info')?>"></i> &nbsp;
                                    <?=db_translate($dept['department'], 'department', $dept['dept_id'])?>
                                </td>
                                <td><?=on($userNums, $userNums, '-')?></td>
                                <td><?=$dept['sort_order']?></td>
                                <td>
                                    <a data-toggle="modal" href="<?=url('department/modal/'.$dept['dept_id'])?>" data-target="#ajax-modal" class="btn btn-xs default">
                                        <i class="fa fa-pencil"></i> <?=__('Edit')?>
                                    </a>
                                    <a href="<?=url('user/list')?>?dept_id=<?=$dept['dept_id']?>" class="btn btn-xs default">
                                        <i class="fa fa-user"></i> <?=__('Staff')?>
                                    </a>
                                    <!--a href="#" class="btn btn-xs default">
                                        <i class="fa fa-unlock"></i> <?=__('Permit')?>
                                    </a-->
                                    <a href="<?=url('department/delete/'.$dept['dept_id'])?>" class="btn btn-xs default ajax-delete">
                                        <i class="fa fa-trash-o"></i> <?=__('Delete')?>
                                    </a>
                                </td>
                            </tr>
                        <? endforeach; ?>
                    </tbody>
                </table>
                <? endif; ?>
            </div>
        </div>
    </div>
</div>
